package com.doudou.zuul.filter.handler;

import com.doudou.zuul.entity.AppAccess;
import lombok.Data;


@Data
public class DefaultLoginVerifyHandler extends LoginVerifyHandler {

    public DefaultLoginVerifyHandler(LoginVerifyHandler nextHandler, AppAccess appAccess) {
        super(appAccess, nextHandler);
    }

    public DefaultLoginVerifyHandler() {

    }

    @Override
    public AppAccess verify(String requestUri, String appName) {

        String loginUrl = getAppAccess().getLoginUrl();
        if (!requestUri.equals(loginUrl)) {
            if (getNextHandler() == null) {
                return null;
            }
            return getNextHandler().verify(requestUri, appName);
        }
        //验证APP_NAME 是不是匹配
        String name = getAppAccess().getName();
        if (appName.equals(name)) {
            return getAppAccess();
        }
        return getNextHandler().verify(requestUri, appName);
    }
}
